import 'package:enterprise_v6_app/app/components/custom_modele/custom_row_title.dart';
import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_title_chart_page.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/data/entities/closure/closure_appointment_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/closure/appointment_review/appointment_review_controller.dart';
import 'package:enterprise_v6_app/app/modules/task/task_all/task_closure/common/common_closure_method.dart';

/// 人员审核
class PersonnelReview extends StatelessWidget {
  PersonnelReview({super.key});

  final controller = Get.put(AppointmentReviewController());

  ///筛选
  Widget _screen() {
    return Container(
      width: 38.w,
      height: 38.w,
      alignment: Alignment.center,
      decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8.w)),
      child: SvgPicture.asset(
        AppImages.icon_search_screen,
        width: 16.w,
      ),
    ).click(() {});
  }

  // 审核状态 0：待审核 1：通过 2：不通过
  Widget _status(int i) {
    switch (i) {
      case 0:
        return Container(
          padding: EdgeInsets.symmetric(vertical: 3.w, horizontal: 10.w),
          decoration: BoxDecoration(
            color: const Color(0xffFFA200),
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(8.r),
              bottomRight: Radius.circular(8.r),
              topRight: Radius.circular(8.r),
            )
          ),
            child: Text('待审核',style: TextStyle(
              fontSize: 10.sp,
              color: Colors.white,
            )),
        );
      case 1:
        return Container(
          padding: EdgeInsets.symmetric(vertical: 3.w, horizontal: 10.w),
          decoration: BoxDecoration(
              color: const Color(0xFF5C6DFF),
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(8.r),
                bottomRight: Radius.circular(8.r),
                topRight: Radius.circular(8.r),
              )
          ),
          child: Text('已通过',style: TextStyle(
            fontSize: 10.sp,
            color: Colors.white,
          )),
        );
      case 2:
        return  Container(
          padding: EdgeInsets.symmetric(vertical: 3.w, horizontal: 10.w),
          decoration: BoxDecoration(
              color: const Color(0xFFFD6B6B),
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(8.r),
                bottomRight: Radius.circular(8.r),
                topRight: Radius.circular(8.r),
              )
          ),
          child: Text('已驳回',style: TextStyle(
            fontSize: 10.sp,
            color: Colors.white,
          )),
        );
      default:
        return const Text('');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(
        horizontal: 16.w,
      ),
      child: Column(
        children: [
          AppGaps.vGap16,
          Expanded(
              child: CustomEasyRefreshList<ClosureAppointmentEntity>(
            isShowSearch: true,
            searchHint: '请输入姓名',
            dataLoad: (pageNum, pageSize, {search}) {
              return controller.checkAssetsDetails(pageNum, pageSize, 0, search: search);
            },
            itemBuilder: (item, index) {
              return CustomTitleChartPage(
                title: item.name,
                titleRightWidget: _status(item.appointmentStatus),
                child:  Column(
                  children: [
                    CustomRowTitle(
                      title: '人员类型:',
                      content: CommonClosureMethod.getPersonTypeValue(item.type),
                    ),
                    CustomRowTitle(
                      title: '所属单位:',
                      content: item.affiliatedUnit,
                    ),
                    CustomRowTitle(
                      title: '预计来访时间:',
                      content: item.startDate,
                    ),
                  ],
                ),
              ).click(() {
                controller.toDetails(0,item);
              });
            },
          ))
        ],
      ),
    );
  }
}
